﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Smartec.Accounts.Camel.AMS.Model.Entities;
using Smartec.Accounts.Camel.AMS.Model.Facades;

namespace Smartec.Accounts.Camel.AMS.WebApp.Controllers
{
    public class AdminLightWordsController : Controller
    {
        //
        // GET: /AdminLightWords/

        public ActionResult Index()
        {
            List<LightWord> LightWords = LightWordFacade.GetAllLightWord();
            return View(LightWords);
        }

        //
        // GET: /News/Details/5

        public ActionResult Details(int id)
        {
            LightWord LightWord = LightWordFacade.GetLightWordById(id);
            return View(LightWord);
        }

        //
        // GET: /News/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /News/Create

        [HttpPost]
        public ActionResult Create(LightWord LightWord)
        {
            try
            {
                // TODO: Add insert logic here
                LightWordFacade.AddLightWord(LightWord);
                LightWordFacade.Save();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /News/Edit/5

        public ActionResult Edit(int id)
        {
            LightWord LightWord = LightWordFacade.GetLightWordById(id);
            return View(LightWord);
        }

        //
        // POST: /News/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, LightWord LightWord)
        {
            try
            {
                // TODO: Add update logic here
                LightWordFacade.UpdateLightWord(LightWord);
                LightWordFacade.Save();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /News/Delete/5

        public ActionResult Delete(int id)
        {
            LightWord LightWord = LightWordFacade.GetLightWordById(id);
            return View(LightWord);
        }

        //
        // POST: /News/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, LightWord LightWord)
        {
            try
            {
                // TODO: Add delete logic here
                LightWordFacade.DeleteLightWordById(id);
                LightWordFacade.Save();
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

    }
}
